<template>
  <el-form
    ref="form"
    :model="form"
    label-width="80px"
    style="max-width:300px;margin:10px auto;border:1px dashed darkgray;padding:10px 100px"
  >
    <el-form-item label="店铺ID:">
      <el-input v-model="form._id" readonly></el-input>
    </el-form-item>
    <el-form-item label="商家ID:">
      <el-input v-model="form.merchantId._id" readonly></el-input>
    </el-form-item>
    <el-form-item label="商家账号:">
      <el-input v-model="form.merchantId.merchantName" readonly></el-input>
    </el-form-item>
    <el-form-item label="手机号:">
      <el-input v-model="form.merchantId.phone" readonly></el-input>
    </el-form-item>
    <el-form-item label="店铺名称:">
      <el-input v-model="form.shopName" readonly></el-input>
    </el-form-item>
    <el-form-item label="申请时间:">
      <el-input v-model="form.appDate" readonly></el-input>
    </el-form-item>
    <el-form-item label="申请描述:">
      <el-input v-model="form.describe" readonly></el-input>
    </el-form-item>
    <el-form-item label="是否冻结:">
      <el-radio-group v-model="form.bool">
        <el-radio label="冻结"></el-radio>
        <el-radio label="不冻结"></el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item>
      <el-button @click="updataFreezeShop(form)">确定</el-button>
    </el-form-item>
  </el-form>
</template>


<script>
const axios = require("axios");
export default {
    created(){
        this.getShopId(this.$route.params._id)
    },
  data() {
    return {
      form: {
        _id: "",
        shopName: "",
        merchantId: "",
        describe: "",
        appDate: "",
        bool: ""
      },
      readonly: true
    };
  },
  methods: {
    async getShopId(_id){
      const {data} = await axios.get('/pAdmins/shopId',{params:{_id}})
        if(data[0].bool===2){
          data[0].bool = '不冻结'
        }else{
          data[0].bool = '冻结'
        }
        this.form = data[0]
    },
    updataFreezeShop(all){
      if(this.form.bool ==='不冻结' ){
          this.form.bool = 2
        }else{
          this.form.bool = 4
        }
        console.info(this.form.bool)
      axios.post('/pAdmins/pAdminUpdateShop',all).then(({data})=>{
        this.$router.push('/admin/adminIndex/shopList')
      })
    }
  }
};
</script>

<style>
.el-input input {
  border: none;
  background-color: rgb(233, 238, 243);
}
</style>